package com.hackordie.operations.deletes;

import com.hackordie.commons.HackOrDieResult;
import com.hackordie.exceptions.HackOrDieException;
import com.hackordie.operations.AHackOrDieOperationComputerType;

public class DeleteComputerType extends AHackOrDieOperationComputerType {

	private final int idComputer;
	private final String name;

	public DeleteComputerType(int idComputer) {
		super();
		this.idComputer = idComputer;
		this.name = "";
	}
	
	public DeleteComputerType(String name) {
        super();
        this.idComputer = -1;
        this.name = name;
    }

	@Override
	protected boolean checkParameters() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	protected HackOrDieResult executeOperation() throws HackOrDieException {
	    if(idComputer == -1) {
	        result.setCorrect(computerTypeDao.delete(name));
	    } else {
	        result.setCorrect(computerTypeDao.delete(idComputer));
	    }
		return result;
	}

}
